package com.kelvin.paopao.module.market.wallet.vip;

import com.kelvin.paopao.api.RetrofitService;
import com.kelvin.paopao.api.responseBean.CommonListResponse;
import com.kelvin.paopao.api.responseBean.VipPriceModel;

import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Action;
import io.reactivex.functions.Consumer;
import rx.functions.ActionN;

/**
 * Created by MCK on 2017/5/23.
 */

public class VipPresenter implements IVipPresenter {
    private VipActivity mView;

    public VipPresenter(VipActivity view) {
        this.mView = view;
    }

    @Override
    public void becomeVip(String id) {
        RetrofitService.becomeVIP(id).subscribe(new Consumer<CommonListResponse>() {
            @Override
            public void accept(@NonNull CommonListResponse commonListResponse) throws Exception {
                if (commonListResponse.getReason().equals("成功")) {
                    mView.finish();
                }
            }
        }, new Consumer<Throwable>() {
            @Override
            public void accept(@NonNull Throwable throwable) throws Exception {

            }
        }, new Action() {
            @Override
            public void run() throws Exception {

            }
        });
    }

    @Override
    public void getData(boolean isRefresh) {
        RetrofitService.getVipPrice().subscribe(new Consumer<CommonListResponse<VipPriceModel>>() {
            @Override
            public void accept(@NonNull CommonListResponse<VipPriceModel>
                                       commonListResponse) throws Exception {
                if (commonListResponse.getReason().equals("成功")) {
                    mView.loadData(commonListResponse.getResult());
                }
            }
        });
    }

    @Override
    public void getMoreData() {

    }
}
